import Taro from '@tarojs/taro'
import { baseUrl  } from '../config'

export function uploadImage (tempFiles) {
  return new Promise((resolve, reject) => {
    Taro.uploadFile({
      url: `${baseUrl}/oss/upload`,
      filePath: tempFiles.url,
      name: 'file',
      formData: {
        name:`image.${tempFiles.file.type.split('/')[1]}`
      },
      success (res) {
        resolve(res.data)
      },
      fail (res) {
        reject(res)
      }
    })
  })
}

